home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / CH6 / EMAGA6 / control / client / misc / transfer.cs < prev   
Text File  |  2003-10-24  |  5KB  |  151 lines

  1. //============================================================================
  2. // control/client/misc/transfer.cs
  3. //
  4. // Copyright (c) 2003 Kenneth C. Finney
  5. //============================================================================
  6.  
  7. //----------------------------------------------------------------------------
  8. // Mission Loading & Mission Info
  9. // The mission loading server handshaking is handled by the
  10. // common/client/missingLoading.cs.  This portion handles the interface
  11. // with the game GUI.
  12. //----------------------------------------------------------------------------
  13.  
  14. //----------------------------------------------------------------------------
  15. // Loading Phases:
  16. // Phase 1: Download Datablocks
  17. // Phase 2: Download Ghost Objects
  18. // Phase 3: Scene Lighting
  19.  
  20. //----------------------------------------------------------------------------
  21. // Phase 1
  22. //----------------------------------------------------------------------------
  23.  
  24. function onMissionDownloadPhase1(%missionName, %musicTrack)
  25. {
  26.    // Reset the loading progress controls:
  27.    LoadingProgress.setValue(0);
  28.    LoadingProgressTxt.setValue("LOADING DATABLOCKS");
  29. }
  30.  
  31. function onPhase1Progress(%progress)
  32. {
  33.    LoadingProgress.setValue(%progress);
  34.    Canvas.repaint();
  35. }
  36.  
  37. function onPhase1Complete()
  38. {
  39. }
  40.  
  41. //----------------------------------------------------------------------------
  42. // Phase 2
  43. //----------------------------------------------------------------------------
  44.  
  45. function onMissionDownloadPhase2()
  46. {
  47.    // Reset the loading progress controls:
  48.    LoadingProgress.setValue(0);
  49.    LoadingProgressTxt.setValue("LOADING OBJECTS");
  50.    Canvas.repaint();
  51. }
  52.  
  53. function onPhase2Progress(%progress)
  54. {
  55.    LoadingProgress.setValue(%progress);
  56.    Canvas.repaint();
  57. }
  58.  
  59. function onPhase2Complete()
  60. {
  61. }
  62.  
  63. function onFileChunkReceived(%fileName, %ofs, %size)
  64. {
  65.    LoadingProgress.setValue(%ofs / %size);
  66.    LoadingProgressTxt.setValue("Downloading " @ %fileName @ "...");
  67. }
  68.  
  69. //----------------------------------------------------------------------------
  70. // Phase 3
  71. //----------------------------------------------------------------------------
  72.  
  73. function onMissionDownloadPhase3()
  74. {
  75.    LoadingProgress.setValue(0);
  76.    LoadingProgressTxt.setValue("LIGHTING MISSION");
  77.    Canvas.repaint();
  78. }
  79.  
  80. function onPhase3Progress(%progress)
  81. {
  82.    LoadingProgress.setValue(%progress);
  83. }
  84.  
  85. function onPhase3Complete()
  86. {
  87.    LoadingProgress.setValue( 1 );
  88.    $lightingMission = false;
  89. }
  90.  
  91. //----------------------------------------------------------------------------
  92. // Mission loading done!
  93. //----------------------------------------------------------------------------
  94.  
  95. function onMissionDownloadComplete()
  96. {
  97.    // Client will shortly be dropped into the game, so this is
  98.    // good place for any last minute gui cleanup.
  99. }
  100.  
  101.  
  102. //------------------------------------------------------------------------------
  103. // Before downloading a mission, the server transmits the mission
  104. // information through these messages.
  105. //------------------------------------------------------------------------------
  106.  
  107. addMessageCallback( 'MsgLoadInfo', handleLoadInfoMessage );
  108. addMessageCallback( 'MsgLoadDescripition', handleLoadDescriptionMessage );
  109. addMessageCallback( 'MsgLoadInfoDone', handleLoadInfoDoneMessage );
  110.  
  111. //------------------------------------------------------------------------------
  112.  
  113. function handleLoadInfoMessage( %msgType, %msgString, %mapName ) {
  114.  
  115.     // Need to pop up the loading gui to display this stuff.
  116.     Canvas.setContent("LoadScreen");
  117.  
  118.     // Clear all of the loading info lines:
  119.     for( %line = 0; %line < LoadScreen.qLineCount; %line++ )
  120.         LoadScreen.qLine[%line] = "";
  121.     LoadScreen.qLineCount = 0;
  122.  
  123.    //
  124.     LOAD_MapName.setText( %mapName );
  125. }
  126.  
  127. //------------------------------------------------------------------------------
  128.  
  129. function handleLoadDescriptionMessage( %msgType, %msgString, %line )
  130. {
  131.     LoadScreen.qLine[LoadScreen.qLineCount] = %line;
  132.     LoadScreen.qLineCount++;
  133.  
  134.    // Gather up all the previous lines, append the current one
  135.    // and stuff it into the control
  136.     %text = "<spush><font:Arial:16>";
  137.  
  138.     for( %line = 0; %line < LoadScreen.qLineCount - 1; %line++ )
  139.         %text = %text @ LoadScreen.qLine[%line] @ " ";
  140.    %text = %text @ LoadScreen.qLine[%line] @ "<spop>";
  141.  
  142.     LOAD_MapDescription.setText( %text );
  143. }
  144.  
  145. //------------------------------------------------------------------------------
  146.  
  147. function handleLoadInfoDoneMessage( %msgType, %msgString )
  148. {
  149.    // This will get called after the last description line is sent.
  150. }
  151.